package com.jt.mapper;

import com.jt.pojo.Teacher;
import com.jt.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface TeacherMapper {
    @Select("select * from teacher")
    List<Teacher> findAll();
    @Select("select * from teacher where name=#{username} and password=#{password}")
    User findUserByUP(User user);
    @Select("select count(1) from teacher")
    long getTotal();
    List<Teacher> findUserListByPage(@Param("start") int start,
                                  @Param("size") int size,
                                  @Param("query") String query);
    /* @Select("select * from user limit #{start},#{size}")
    List<User> findUserListByPage(@Param("start") int start,@Param("size") int size);*/

    @Update("update teacher set status = #{status} where id=#{id}")
    void updateStatus(Teacher teacher);

    void addUser(User user);

    //原理: mybatis在进行单值传递时(int等基本类型/string) 取值时名称任意
    //     底层通过下标[0]获取的数据和名称无关.
    @Select("select * from teacher where id=#{id}")
    Teacher findUserById(Integer id);

    @Update("update teacher set score=#{score},profession=#{profession},serve=#{serve},reversion=#{reversion} where id=#{id}")
    void updateUser(Teacher teacher);

    @Delete("delete from teacher where id=#{id}")
    void deleteUserById(Integer id);
}
